﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace GrayParrot.Web.Formly
{
    public class UISelect2TemplateOptionsAttribute : OptionsTemplateOptionsAttribute
    {
                /// <summary>
        /// Gets or sets the name of the property that is used to group the options...
        /// </summary>
        /// <value>
        /// The group property.
        /// </value>
        [JsonProperty(PropertyName = "groupProp")]
        public string GroupProp { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [force load].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [force load]; otherwise, <c>false</c>.
        /// </value>
        [JsonProperty(PropertyName = "forceLoad")]
        public bool ForceLoad { get; set; }

        /// <summary>
        /// Gets or sets the options attribute.
        /// </summary>
        /// <value>
        /// The options attribute.
        /// </value>
        [JsonProperty(PropertyName = "optionsAttr")]
        public string OptionsAttr { get; set; }

        /// <summary>
        /// Gets the ng options.
        /// </summary>
        /// <value>
        /// The ng options.
        /// </value>
        [JsonProperty(PropertyName = "ngOptions")]
        public string NgOptions { get; internal set; }

        /// <summary>
        /// Gets or sets the refresh delay.
        /// </summary>
        /// <value>
        /// The refresh delay.
        /// </value>
        [JsonProperty(PropertyName = "refreshDelay")]
        public int RefreshDelay { get; set; }

        /// <summary>
        /// Gets or sets the refresh items.
        /// </summary>
        /// <value>
        /// The refresh items.
        /// </value>
        [JsonProperty(PropertyName = "refresh")]
        public object Refresh { get; set; }

        /// <summary>
        /// Gets or sets the minimum length of the input.
        /// </summary>
        /// <value>
        /// The minimum length of the input.
        /// </value>
        [JsonProperty(PropertyName = "minimumInputLength")]
        public uint MinimumInputLength { get; set; }

        /// <summary>
        /// Gets or sets the edit property.
        /// </summary>
        /// <value>
        /// The edit property.
        /// </value>
        [JsonProperty(PropertyName = "editProp")]
        public string EditProp { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="SelectTemplateOptionsAttribute"/> class.
        /// </summary>
        public UISelect2TemplateOptionsAttribute()
        {
            this.ForceLoad = false;
            this.OptionsAttr = "bs-options";
            this.NgOptions = "option[to.valueProp] as option in to.options | filter: $select.search";
            this.RefreshDelay = 0;
            this.Refresh = "refreshItems";
        }
    }
}
